<script setup>
import {onMounted, ref} from 'vue'
import {pageApi} from "../../../api/resource";

const tableData = ref({})

// 表单状态
const filterState = ref(true)
// 表单数据
const formData = ref({
  page: 1,
  size: 10,
  name: ''
})

onMounted(()=>{
  loadData()
})

const loadData=()=>{
  pageApi(formData.value).then(r=>{
    tableData.value=r.data;
  })
}

</script>
<template>
  <Box>
    <!-- 筛选 -->
    <template #filter v-if="filterState">
      <el-form :inline="true" :model="formData">
        <el-form-item label="对象名称">
          <el-input placeholder="请输入对象名称" v-model="formData.name" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="loadData"> <span class="iconfont icon-sousuo"></span>搜索 </el-button>
          <el-button type="default"> 重置 </el-button>
        </el-form-item>
      </el-form>
    </template>
    <!-- 筛选 -->

    <!-- 按钮组 -->
<!--    <el-row>-->
<!--      <el-col :span="12" style="text-align: right">-->
<!--        <el-button circle @click="filterState = !filterState">-->
<!--          <span class="iconfont icon-sousuo"></span>-->
<!--        </el-button>-->
<!--        <el-button circle>-->
<!--          <span class="iconfont icon-shuaxin"></span>-->
<!--        </el-button>-->
<!--      </el-col>-->
<!--    </el-row>-->
    <!-- 按钮组 -->

    <el-table :data="tableData.data" :border="true" class="qfTable" row-key="id" default-expand-all>
      <el-table-column label="序号" prop="id" align="center"></el-table-column>
      <el-table-column label="桶名称" prop="bucket" align="center"></el-table-column>
      <el-table-column label="对象名称" prop="objName" align="center"></el-table-column>
      <el-table-column label="类型" prop="contentType" align="center"></el-table-column>
      <el-table-column label="大小" prop="size" align="center"></el-table-column>
      <el-table-column label="创建时间" prop="ctime" align="center"></el-table-column>
      <el-table-column label="访问地址" align="center">
        <template #default="scope">
          <span><a :href="scope.row.url">{{scope.row.url}}</a> </span>
        </template>
      </el-table-column>

    </el-table>
    <el-pagination
        v-model:current-page="formData.pagenum"
        v-model:page-size="formData.pagesize"
        :page-sizes="[10, 20, 30, 40]"
        :background="true"
        layout="total, sizes, prev, pager, next, jumper"
        :total="tableData.total"
        @size-change="loadData"
        @current-change="loadData"
    />

  </Box>
</template>

<style lang="scss" scoped></style>
